package edu.zut.main.thread;

public class ThreadJoin {

    public static void main(String[] args) {

        Thread thread = new Thread(new VIPThread());
        thread.start();

        for (int i = 1; i <= 50; i++) {
            if (i == 10){
                try {
                    thread.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("普通客户-" + i + "该你了");

        }

    }

}
//线程的联合：一个已经获取cpu资源的线程A，调用join后将就绪线程B联合进来，
//此时，A会挂起，B获取资源，B执行结束后，A重新转为就绪，等待CPU调度
class VIPThread implements Runnable{

    @Override
    public void run() {
        for (int i = 1; i < 11 ; i++) {
            System.out.println("VIP-" + i + " 插队");
        }
    }
}



